package com.xiaozhengkeji.bukkit.chunkmanager;

import org.bukkit.World;
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
import org.bukkit.event.Listener;
import org.bukkit.event.world.ChunkEvent;
import org.bukkit.event.world.ChunkLoadEvent;
import org.bukkit.event.world.ChunkUnloadEvent;

import java.awt.font.FontRenderContext;

/**
 * 区块事件监听器
 */
public class ChunkListener implements Listener {

    public static Long ChunkUnloadSize = 0L;

    @EventHandler(priority = EventPriority.HIGHEST)
    public void onChunkUnload(ChunkUnloadEvent event) {
        event.setCancelled(true);
        for (World world : ChunkManagerService.UN_CHUNK_MAP.keySet()) {
            if (ChunkManagerService.UN_CHUNK_MAP.get(world).contains(event.getChunk())) {
                event.setCancelled(false);
                ChunkManagerService.UN_CHUNK_MAP.get(world).remove(event.getChunk());
            }
        }
    }

    @EventHandler(priority = EventPriority.HIGHEST)
    public void onChunkLoad(ChunkLoadEvent event) {

    }


}
